<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>杨澎锴学习实践16——JS基础知识练习</title>
    <!-- <script src="hellow.js"></script> -->
  </head>
  <!-- 逻辑加数据就变成了程序 -->
  <body>
    <p id="demo" onclick="hello()">单击这段文字！</p>
    <!-- <script>
      function hello() {
        document.getElementById("demo").innerHTML = "你好，JavaScript 世界！";
      }
    </script> -->
    <!-- 将js代码写在html行内 -->
    <input type="button" value="按钮" onclick="alert(123)" />
    <!-- 在script的标签中的js -->
    <!-- <script>
      //   console.log(3456);
    //   var name = "ypkai";
    //   const school = "xxxx";
    //   //   school = "a";
    //   let age = 23;
    //   console.log(name, school, age);
    //   console.log(5 === "5");
    //   console.log(name + age);
    //   console.log(age + age);
    //   if (age > 35) {
    //     console.log("你不能申报青年项目。");
    //   } else {
    //     console.log("你可以申报青年项目");
    //   }
    //   var txt1 = "javs";
    //   var txt2 = "learn";
    //   var txt3 = txt1 + txt2;
    //   console.log(txt1, txt2);
    //   console.log(txt3);
    // </script> -->
    <script>
      const a = 2;
      //变量必须有意义，注意：区分大小
      //如果变量的名字重复了，后面的内容自动覆盖前面的内容
      var message = "a这是来自变量的信息";
      console.log(message, a);
      const b = 3;
      console.log(a + b);
      if (a >= 5) {
        console.log("555");
      } else {
        console.log("683");
      }
      var weight = "部分失实";
      switch (weight) {
        case "谣言":
          console.log("这是一个谣言");
          break;
        case "部分失实":
          console.log("部分信息有误");
          break;
        case "确有此事":
          console.log("确有此事");
          break;
        default:
          break;
      }
      for (var index = 6; index <= 9; index++) {
        console.log(index);
      }
      var i = "7";
      while (i == 7) {
        console.log(i);
        i++;
      }
      function name(message) {
        console.log(message);
      }
      //使用英文的引号包裹起来的就是字符串
      // 还有转义字符的使用"/"
      name("jackma");
      name("chen");
      function score(params) {
        return 100;
      }
      // score后面没有括号时，直接输出函数的内容
      console.log(score());
      var d = "true";
      var e = true;
      // typeof检测代码
      console.log(d, e, typeof d, typeof e);
      var f;
      console.log(f, typeof f);
      console.log(message.toUpperCase());
      var num1 = 54;
      var num2 = 5.4;
      console.log(num1, typeof num1);
      console.log(num2, typeof num2);
      console.log(b, typeof b);
      var h = "2";
      console.log(typeof Boolean("h"), Boolean(h));

      var n = 6;
      // 使用字符串的规则。采用“+”的属性来实现数值转换成字符串
      var s = "" + n;
      console.log(typeof s);
    </script>
  </body>
</html>
